package com.sc.bean;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;

/**
 * 
 * @Description 自定义序列化类Spend
 * @author pengjun
 * @version v1.0
 * @date 2020年7月10日
 */
public class SpendSecond implements Writable{

	//可定义无数个参数...
	private Text name;
	private FloatWritable money;
	private Text city;
	
	public SpendSecond() {
		super();
	}

	public SpendSecond(Text name, FloatWritable money, Text city) {
		super();
		this.name = name;
		this.money = money;
		this.city = city;
	}

	public Text getName() {
		return name;
	}

	public void setName(Text name) {
		this.name = name;
	}

	public FloatWritable getMoney() {
		return money;
	}

	public void setMoney(FloatWritable money) {
		this.money = money;
	}

	public Text getCity() {
		return city;
	}

	public void setCity(Text city) {
		this.city = city;
	}

	@Override
	public void write(DataOutput out) throws IOException {
		// TODO Auto-generated method stub
		name.write(out);
		money.write(out);
		city.write(out);
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		// TODO Auto-generated method stub
		name = new Text();
		name.readFields(in);
		
		money = new FloatWritable();
		money.readFields(in);
		
		city = new Text();
		city.readFields(in);
	}

	@Override
	public String toString() {
		return name + "," + city + "," + money;
	}
}
